/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.ubinow.mflex.baseui;

import net.ubinow.mflex.data.IDataItem;


/**
 * IStatefulView is a more 'practical' interface to the IView which enforces the basics 
 * to be implemented such as handling keyPresses, positioning, and rendering. This interface is 
 * for those viewable menus that are used in an application. They ensure that convienient 
 * methods are implemented in the implementing classes that help with general application 
 * management. 
 * @author Josh
 */
public interface IStatefulView extends IWidget {
    /**
     * returns the previous view (view that instantiated this one)
     * @return
     */
    public IStatefulView getPreviousView();
    
    /**
     * sets the previous view for this instance 
     * @param view
     */
    public void setPreviousView( IStatefulView view );
    
    /**
     * clear out view data so this can be re-used without re-creating the view again
     */
    public void flush();
    
    /**
     * associate some data to this view, useful when going to the next screen but would like 
     * to fetch some piece of selected data
     * @param key: key used to fetch the attachment
     * @param value: the value associated with the key
     */
    public void addAttachment( String key, IDataItem value );
    
    /**
     * fetch an associated bit of data to this view
     * @param key: key that is associated to the data 
     * @param removeFromView: if true; then once returned it will be removed from the view
     * @return
     */
    public IDataItem getAttachment( String key, boolean removeFromView );
    
    /**
     * associate some data to this view, useful when going to the next screen but would like 
     * to fetch some piece of selected data
     * @param key: key used to fetch the attachment
     * @param values: the values associated with the key
     */
    public void addAttachments( String key, IDataItem[] values );
    
    /**
     * fetch an associated bit of data to this view
     * @param key: key that is associated to the data 
     * @param removeFromView: if true; then once returned it will be removed from the view
     * @return
     */
    public IDataItem[] getAttachments( String key, boolean removeFromView );
    
}
